//package com.ld.security.common.mybatis.config;
//
//
//import com.alibaba.druid.pool.DruidDataSource;
//import com.alibaba.druid.wall.WallConfig;
//import com.alibaba.druid.wall.WallFilter;
//import org.springframework.beans.wrapper.annotation.Autowired;
//import org.springframework.boot.autoconfigure.AutoConfigureBefore;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
//import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
//import org.springframework.boot.context.properties.EnableConfigurationProperties;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
//import javax.sql.DataSource;
//import java.sql.SQLException;
//import java.util.ArrayList;
//
//
//@Configuration
//@EnableConfigurationProperties(DruidProperties.class)
//@ConditionalOnClass(DruidDataSource.class)
//@ConditionalOnProperty(prefix = "druid", name = "url")
//@AutoConfigureBefore(DataSourceAutoConfiguration.class)
//public class DruidAutoConfiguration {
//    @Autowired
//    private DruidProperties properties;
//
//    @Bean(name = "wallFilter")
//    public WallFilter wallFilter() {
//        WallConfig wallConfig = new WallConfig();
//        //允许sql批量操作
//        wallConfig.setMultiStatementAllow(true);
//        wallConfig.setNoneBaseStatementAllow(true);//允许非基本语句的其他语句
//        WallFilter wfilter = new WallFilter();
//        wfilter.setConfig(wallConfig);
//        return wfilter;
//    }
//
//    //@Bean
//    public DataSource dataSource() {
//        DruidDataSource dataSource = new DruidDataSource();
//        dataSource.setUrl(properties.getUrl());
//        dataSource.setUsername(properties.getUsername());
//        dataSource.setPassword(properties.getPassword());
//        if (properties.getInitialSize() > 0) {
//            dataSource.setInitialSize(properties.getInitialSize());
//        }
//        if (properties.getMinIdle() > 0) {
//            dataSource.setMinIdle(properties.getMinIdle());
//        }
//        if (properties.getMaxActive() > 0) {
//            dataSource.setMaxActive(properties.getMaxActive());
//        }
//        dataSource.setTestOnBorrow(properties.isTestOnBorrow());
//        try {
//            ArrayList arrayList = new ArrayList<>();
//            arrayList.add(this.wallFilter());
//            dataSource.setProxyFilters(arrayList);
//            dataSource.setFilters("stat");
//            dataSource.init();
//        } catch (SQLException e) {
//            throw new RuntimeException(e);
//        }
//        return dataSource;
//    }
//
//}